<!-- 个人中心 -->
<template>
	<view class="personal-wrap">
		<!-- 个人信息卡片 -->
		<userinfo-card v-if="userHeadData && userHeadData.style" :scrollTop="scrollTop" :detail="userHeadData" @onShare="onShare"></userinfo-card>
		<!-- 钱包 -->
		<!-- <sh-wallet></sh-wallet> -->
		<image class="wallet_imgbox" :src="`${$IMG_URLT}user_01.png`"></image>
		<view class="wallet">
			<image class="wallet_img" :src="$IMG_URLT + 'user_02.png'"></image>
			<view class="wallet_num">{{userInfo.money || '0'}}</view>
			<view class="wallet_btn btn1" @tap="jump('/pages/points/points')">积分明细</view>
			<view class="wallet_btn btn2" @tap="jump('/pages/points/pointspay')">积分充值</view>
		</view>
		<!-- 订单卡片 -->
		<!-- <sh-order-card></sh-order-card> -->
		<view class="list_box">
			<view class="u-flex u-row-between list" @tap="jump('/pages/order/listtwo')">
				<view class="list_name">我的猫咪</view>
				<text
				  class="u-iconfont uicon-arrow-right"
				  style="color: #bfbfbf"
				></text>
			</view>
			<!-- <view class="u-flex u-row-between list" @tap="jump('/pages/index/cart')">
				<view class="list_name">我的购物车</view>
				<text
				  class="u-iconfont uicon-arrow-right"
				  style="color: #bfbfbf"
				></text>
			</view> -->
			<view class="u-flex u-row-between list" @tap="jump('/pages/user/address/list')">
				<view class="list_name">收货地址</view>
				<text
				  class="u-iconfont uicon-arrow-right"
				  style="color: #bfbfbf"
				></text>
			</view>
			<view class="u-flex u-row-between list" @tap="confirmLogOut">
				<view class="list_name">退出登录</view>
				<text
				  class="u-iconfont uicon-arrow-right"
				  style="color: #bfbfbf"
				></text>
			</view>
		</view>
		<!-- 自定义模块 -->
		<!-- <view v-for="(item, index) in userTemplate" :key="item.id"> -->
			<!-- 轮播 -->
			<!-- <sh-banner
				v-if="item.type === 'banner' && index !== 0"
				:Px="item.content.x"
				:Py="item.content.y"
				:borderRadius="item.content.radius"
				:height="item.content.height"
				:list="item.content.list"
			></sh-banner> -->
			<!-- 滑动宫格 -->
			<!-- <sh-grid-swiper v-if="item.type === 'menu'" :list="item.content.list" :oneRowNum="item.content.style"></sh-grid-swiper> -->
			<!-- 广告魔方 -->
			<!-- <sh-adv v-if="item.type === 'adv'" :detail="item.content"></sh-adv> -->
			<!-- 推荐商品 -->
			<!-- <sh-hot-goods v-if="item.type === 'goods-list' || item.type === 'goods-group'" :detail="item.content"></sh-hot-goods> -->
			<!-- 富文本 -->
			<!-- <sh-richtext v-if="item.type === 'rich-text'" :richId="item.content.id"></sh-richtext> -->
			<!-- 功能列表 -->
			<!-- <sh-cell v-if="item.type === 'nav-list'" :list="item.content.list"></sh-cell> -->
			<!-- 九宫格列表 -->
			<!-- <sh-grid v-if="item.type === 'grid-list'" :list="item.content.list"></sh-grid> -->
			
		<!-- </view> -->
		<!-- copyright -->
		<!-- <view class="copyright-box u-flex-col u-row-center u-col-center u-p-t-80 u-p-b-50" v-if="initShop.copyright">
			<view class="copyright-text">{{ initShop.copyright[0] }}</view>
			<view class="copyright-text">{{ initShop.copyright[1] }}</view>
		</view> -->

		<!-- #ifdef H5 -->
		<!-- <view class="tabbar-hack" style="height: 120rpx; width:100%;"></view> -->
		<!-- #endif -->
		<!-- 关注弹窗 -->
		<!-- <shopro-float-btn></shopro-float-btn> -->
		<!-- 登录提示 -->
		<shopro-auth-modal></shopro-auth-modal>
		<!-- 分享组件 -->
		<!-- <shopro-share v-model="showShare" posterType="user"></shopro-share> -->
		<!-- <shopro-tabbar></shopro-tabbar> -->
	</view>
</template>

<script>
import shBanner from './components/sh-banner.vue';
import shGridSwiper from './components/sh-grid-swiper.vue';
import shAdv from './components/sh-adv.vue';
import shRichtext from './components/sh-richtext.vue';
import shCell from './components/sh-cell.vue';
import shGrid from './components/sh-grid.vue';
import shOrderCard from './components/sh-order-card.vue';
import shWallet from './components/sh-wallet.vue';
import shHotGoods from './components/sh-hot-goods.vue';

import userinfoCard from './user/userinfo-card.vue';

import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';

import share from '@/shopro/share';

export default {
	components: {
		shBanner,
		shGridSwiper,
		shAdv,
		shRichtext,
		shCell,
		shGrid,
		shWallet,
		shOrderCard,
		shHotGoods,

		userinfoCard
	},
	data() {
		return {
			scrollTop: 0,
			showShare: false,
			enable: false ,//是否开启吸顶。
			// bgimgs:require('@/static/images/user_01.png')
		};
	},
	computed: {
		...mapGetters(['initShop', 'userTemplate', 'isLogin', 'userInfo', 'authType']),
		userHeadData() {
			if (this.userTemplate?.length) {
				return this.userTemplate[0].content;
			}
		}
	},
	// 下拉刷新
	onPullDownRefresh() {
		this.init();
	},
	onPageScroll(e) {
		this.scrollTop = e.scrollTop;
	},

	onShow() {
		if (this.isLogin) {
			this.init();
			this.getUserData();
		}
		this.enable = true;
	},

	methods: {
		...mapActions(['getUserInfo', 'showAuthModal', 'getUserData',"logout"]),
		
		onShare() {
			// this.showShare = true;
			// uni.hideTabBar();
		},
		// 初始化
		init() {
			this.getUserInfo()
				.then(res => {
					uni.stopPullDownRefresh();
				})
				.catch(e => {
					uni.stopPullDownRefresh();
				});
		},
		jump(path, query) {
			this.$Router.push({
				path: path,
				query: query
			});
		},
		// 退出登录
		confirmLogOut() {
			this.logout();
			this.$Router.back();
		},
	}
};
</script>

<style lang="scss">
.copyright-box {
	.copyright-text {
		font-size: 22rpx;
		font-weight: 500;
		color: #c4c4c4;
	}
}
.list_box{
	box-sizing:border-box;
	width: 702rpx;
	background: #FFFFFF;
	border-radius: 16rpx;
	padding:0 32rpx;
	margin:0 auto;
	margin-top:24rpx;
	.list{
		height: 108rpx;
		border-bottom:2rpx solid rgba(228,228,228,0.42) ;
		.list_name{
			font-size: 28rpx;
			color: #111111;
		}
	}
}
.wallet_imgbox{
	display: block;
	width: 702rpx;
	height: 116rpx;
	margin:0 auto;
}
.wallet{
	box-sizing:border-box;
	display: flex;
	width: 702rpx;
	height: 116rpx;
	
	padding:0 24rpx 0 32rpx;
	align-items: center;
	margin:0 auto;
	margin-top:-116rpx;
	position: relative;
	z-index: 99;
	.wallet_img{
		width: 40rpx;
		height: 40rpx;
	}
	.wallet_num{
		font-size: 40rpx;
		color: #FFFAE6;
		margin-left:8rpx;
	}
	.wallet_btn{
		width: 136rpx;
		height: 56rpx;
		border-radius: 28rpx;
		border: 2rpx solid #FFF3E6;
		text-align: center;
		line-height: 56rpx;
		font-size: 24rpx;
	}
	.btn1{
		color: #FFF3E6;
		margin-left:auto;
	}
	.btn2{
		color: #FC994E;
		background: #FFFAE6;
		margin-left:10rpx;
	}
}
</style>
